package com.ygg.controller;

import com.ygg.model.hosp.Hospital;
import com.ygg.result.Result;
import com.ygg.service.HospitalService;
import com.ygg.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Resource
    private HospitalService hospitalService;

    @ApiOperation(value = "获取分页列表")
    @PostMapping("list/{page}/{pageSize}")
    public Result<Page<Hospital>> list(@PathVariable Integer page,
                                       @PathVariable Integer pageSize,
                                       @RequestBody HospitalQueryVo vo) {
        Page<Hospital> pages = hospitalService.list(page, pageSize, vo);

        return Result.ok(pages);
    }

    @ApiOperation(value = "修改医院状态")
    @PutMapping("/updateStatus/{id}/{status}")
    public Result<String> updateStatus(@PathVariable String id,
                                       @PathVariable Integer status) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }


    @GetMapping("showHospDetail/{id}")
    public Result<Map<String,Object>> show(@PathVariable String id) {
       Map<String,Object> map =  hospitalService.show(id);
       return Result.ok(map);
    }


}
